const { notEmpty } = require('../utils.js')

module.exports = {
  description: 'generate component, include component, render and render config',
  prompts: [{
    type: 'input',
    name: 'name',
    message: 'component name please',
    validate: notEmpty('name')
  },
  {
    type: 'input',
    name: 'label',
    message: 'component label please',
    validate: notEmpty('label')
  },
  {
    type: 'input',
    name: 'index',
    message: 'component index please',
    default: 'Z'
  },
  {
    type: 'rawlist',
    name: 'category',
    message: 'component category please',
    choices: ['basic', 'advance', 'layout'],
    default: 'basic'
  },
  {
    type: 'confirm',
    name: 'isContainer',
    message: 'component is container',
    default: false
  }],
  actions: data => {
    const name = '{{name}}'
    const category = '{{category}}'
    const actions = [{
      type: 'add',
      path: `packages/element-form-design/src/components/${category}/${name}.js`,
      templateFile: 'plop-templates/component/component.hbs'
    },
    {
      type: 'add',
      path: `packages/element-form-design/src/components/${category}/${name}-render.vue`,
      templateFile: 'plop-templates/component/component-render.hbs'
    },
    {
      type: 'add',
      path: `packages/element-form-design/src/components/${category}/${name}-render-config.vue`,
      templateFile: 'plop-templates/component/component-render-config.hbs'
    }]

    return actions
  }
}
